package com.demo.nio;

import java.util.Scanner;

public class Client {
    private static ClientHandler clientHandler;
    //向服务器发送消息  
    public static boolean sendMsg(String msg) throws Exception{  
        clientHandler.sendMsg(msg);  
        return true;
    }
	public static void main(String[] args) {
		// 运行客户端
        clientHandler = new ClientHandler("127.0.0.1",8081);
        new Thread(clientHandler,"Server").start();
		try {
			while (Client.sendMsg(new Scanner(System.in).nextLine()));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
